module testbench; 
semaphore s1 = new(1);

task t1();
for (int i = 0;i<4 ;i++ ) begin
    s1.get(1);
    $display("t1 get");
    #1 ;
    s1.put(1);
    $display("t1 put");
    #1 ;
end
endtask

task t2();
for (int i = 0;i<4 ;i++ ) begin
    s1.get(1);
    $display("\tt2 get");
    #3;
    s1.put(1);
    $display("\tt2 put");
    #3;
end
endtask

initial begin
    $display("\033[32m\t\t!!\tcode begin\t!!");  
    fork
        t1();
        t2();
    join
    $display("\t\t!!\tcode end\t!!\033[0m");
    $finish; 
end 
endmodule 